export default {
	isArray(o){
		return Object.prototype.toString.call(o)=='[object Array]';
	},

	swapArray(arr, index1, index2) {
	arr[index1] = arr.splice(index2, 1, arr[index1])[0];
	return arr;
	},

	reLogin(){
		this.$store.dispatch('deleteToken')
		this.$store.dispatch('deleteUserModel')
		this.$store.dispatch('deletePendingActNum')
		this.$store.dispatch('deleteUrlParams')
		this.$store.dispatch('deletelastLoginAs')
		location.replace('/login')
	},

	getQueryStringArgs(url){
		url = url == null ? window.location.href : url;
		var qs = url.substring(url.lastIndexOf("?") + 1);
		var args = {};
		var items = qs.length > 0 ? qs.split('&') : [];
		var item = null;
		var name = null;
		var value = null;
		for(var i=0; i<items.length; i++){
			item = items[i].split("=");
			//用decodeURIComponent()分别解码name 和value（因为查询字符串应该是被编码过的）。
			name = decodeURIComponent(item[0]);
			value = decodeURIComponent(item[1]);

			if(name.length){
				args[name] = value;
			}
		}

		return args;
	}



}


